package com.hotline.communication.manager;

import com.hotline.communication.mapper.RegisterMapper;
import com.hotline.communication.mapper.SatisfactionMapper;
import com.hotline.communication.dto.RegisterDTO;
import com.hotline.communication.dto.SatisfactionDTO;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 满意度管理类
 *
 * @author yeshengqi
 */
@Component
@Transactional(rollbackFor = Exception.class)
public class SatisfactionManager {

    @Resource
    private SatisfactionMapper satisfactionDao;

    @Resource
    private RegisterMapper registerDao;

    @Transactional(rollbackFor = Exception.class)
    public void insert(SatisfactionDTO satisfactionDTO) {
        satisfactionDao.insert(satisfactionDTO);

        //更新满意度调查标志
        RegisterDTO registerDTO = new RegisterDTO();
        registerDTO.setCallId(satisfactionDTO.getCallId());
        registerDTO.setIsSatisfaction(1);
        registerDao.update(registerDTO);
    }
}
